package com.my.chapter8;

public class practice17 {
    public static void main(String[] args) {
        Cycle2[] c= {new Unicycle2(),new Bicycle2(),new Tricycle2()};
        c[0].balance();
        c[1].balance();
        c[2].balance();
        ((Unicycle2)c[0]).balance();
        ((Bicycle2)c[1]).balance();
        ((Tricycle2)c[2]).balance();
    }
}

class Cycle2{
    public Cycle2(){
        System.out.println("Cycle");
    }
    void balance() {
        System.out.println("Cycle.balance()");
    }
}
class Unicycle2 extends Cycle2{
    public Unicycle2(){
        System.out.println("Unicycyle");
    }
    void balance() {
        System.out.println("Unicycle.balance()");
    }
}
class Bicycle2 extends Cycle2{
    public Bicycle2(){
        System.out.println("Bicycle");
    }
    void balance() {
        System.out.println("Bicycle.balance()");
    }
}
class Tricycle2 extends Cycle2{
    public Tricycle2(){
        System.out.println("Tricycle");
    }
}

